package com.zhong.gang.pda.ui.main;

import android.text.TextUtils;
import android.view.View;

import androidx.databinding.DataBindingUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zhong.gang.applib.utils.TimeUtils;
import com.zhong.gang.pda.R;
import com.zhong.gang.pda.databinding.ItemMainBinding;
import com.zhong.gang.pda.db.loction.LocationMessageUtils;
import com.zhong.gang.pda.ui.action.HuoBean;
import com.zhong.gang.pda.ui.action.deliver.DeliverAct;
import com.zhong.gang.pda.ui.action.receive.ReceiveAct;

public class MainAdapter extends BaseQuickAdapter<MainBean, BaseViewHolder> {
    public MainAdapter() {
        super(R.layout.item_main);
    }

    @Override
    protected void convert(BaseViewHolder helper, MainBean item) {
        ItemMainBinding binding = DataBindingUtil.bind(helper.itemView);
        binding.carNum.setText("车牌号:"+item.getCarNum());
        if (TextUtils.isEmpty(item.getSecondTime())){
            binding.endTime.setText("出场时间：未出场");
            binding.status.setText("场内");
            binding.status.setBackgroundResource(R.drawable.bg_orange_radius3);
        }else {
            binding.endTime.setText("出场时间："+ TimeUtils.getTime(item.getSecondTime()));
            binding.status.setText("已出场");
            binding.status.setBackgroundResource(R.drawable.bg_green_radius3);
        }
        binding.startTime.setText("进场时间："+TimeUtils.getTime(item.getFirstTime()));
        switch (item.getType()){
            case 1://发货
                binding.type.setText("料场发货");
                break;
            case 2://收货
                binding.type.setText("料场收货");
                break;
            default:
                HuoBean huoBean = LocationMessageUtils.getIntent(mContext).getData(item.getId());
                if (huoBean != null){
                    switch (huoBean.getType()){
                        case 1://发货
                            binding.type.setText("料场发货");
                            break;
                        case 2://收货
                            binding.type.setText("料场收货");
                            break;
                        default:
                            binding.type.setText("待处理");
                    }
                }else {
                    binding.type.setText("待处理");
                }
                break;
        }
    }
}
